package com.opal.qualityControl.controller;

import com.opal.qualityControl.entity.CheckoutResult;
import com.opal.qualityControl.DTO.RawMaterialResultDTO;
import com.opal.qualityControl.service.RawMaterialReportService;
import com.opal.vo.GrfTableVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

//原料验厂报告
@Controller
@RequestMapping("/qualityControl")
public class QualityController {


    @Autowired
    private RawMaterialReportService rawMaterialReportService;

    /**
     * 获取材料信息与检验结果--打印导出
     * @param batchCode
     * @return
     */
    @RequestMapping("/RawMaterialReport")
    @ResponseBody
    public GrfTableVO<RawMaterialResultDTO> RawMaterialReport(@RequestParam("batchCode")String batchCode,
                                                              @RequestBody List<CheckoutResult> checkoutResult){
        return rawMaterialReportService.getRawMaterialResult(batchCode,checkoutResult);
    }


    /**
     * 获取检验结果
     * @param batchCode
     * @return
     */
    @RequestMapping("/getCheckoutResult")
    @ResponseBody
    private List<CheckoutResult> getCheckoutResult(String batchCode){
        return rawMaterialReportService.getCheckoutResult(batchCode);
    }

    @RequestMapping("{page}")
    public String skipPage(@PathVariable("page") String page) {
        return "qualityControl/" + page;
    }
}
